<?php
/*********************************************************************\
* This File is a part of BH-PANEL (Breizh-Heberg Panel v2.1)
* Copyright (C) 2008-2009 the BH Developpers : Vincent Giersch <mail@vincordi.fr>, Cyprien Laleau <fanning.fr@gmail.com> and Edwin Cabiten <marmottes44@hotmail.fr>
* See file AUTHORS to get more informations

* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
/*********************************************************************/


include ROOT.'php/lib/actions.php';
include ROOT.'php/lib/servers.php';
if(REQUEST_AJAX != 1) {
	$liste_hebergs = query("SELECT id, user_linux, UNIX_TIMESTAMP(expire), offre FROM comptes_heberg WHERE u_nic='".$_SESSION['u_nic']."'");
	$liste_doms = query("SELECT id,domaine, UNIX_TIMESTAMP(expire)  FROM comptes_domain WHERE u_nic='".$_SESSION['u_nic']."'");
		While($heberg = mysql_fetch_array($liste_hebergs)) {
			if($heberg['UNIX_TIMESTAMP(expire)'] < (time()+3600*24*7)) {  $red_expire = 1; } else {	$red_expire = 0;}
			if(($heberg['UNIX_TIMESTAMP(expire)'] == 0)||($heberg['UNIX_TIMESTAMP(expire)'] == "")) {
				$expire = "";		
			}
			else {
				$expire = date('d/m/Y H:i', $heberg['UNIX_TIMESTAMP(expire)']);
			}
			
			$tpl->assign_array('hebergs',array(
				'id' => $heberg['id'],
				'user_linux' => $heberg['user_linux'],
				'expire' => $expire,
				'red_expire' => $red_expire,
				'offre' => $heberg['offre']
			));	
		}	
		While($doms = mysql_fetch_array($liste_doms)) {
			if($doms['UNIX_TIMESTAMP(expire)'] < (time()+3600*24*7)) {  $red_expire = 1; } else {	$red_expire = 0;}
			if($doms['UNIX_TIMESTAMP(expire)'] == 0) {
				$expire = "";	
			}
			else {
				$expire = date('d/m/Y H:i', $doms['UNIX_TIMESTAMP(expire)']);
			}
			$tpl->assign_array('doms',array(
				'id' => $doms['id'],
				'domaine' => $doms['domaine'],
				'expire' => $expire,
				'red_expire' => $red_expire
			));	
		}
	$tpl->assign(array(
		'pma' => $bzh_config['pma'],
		'webftp' => $bzh_config['webftp'],
	));
}
?>